// 给服务器发送一个请求，告诉服务器要发送100字节的数据，但实际发送的数据不足1024，看服务器处理结果

/*
    1、如果服务器得不到完整请求，就不进行业务处理，客户端得不到响应，超时关闭
    2、告诉服务器正文有100字节，所以服务器一直在等，这时候连着给服务器发送多次请求，服务器就可能将后面的请求也当作正文处理，导致错误
*/

#include "httpserver.hpp"

int main()
{
    Socket client_sock;
    client_sock.CreateClient(8202, "127.0.0.1");
    std::string req = "GET /hello HTTP/1.1\r\nConnection: keep-alive\r\nContent-Length: 100\r\n\r\n这是100字节的数据~";
    
    assert(client_sock.Send(&req[0], req.size()) != -1);
    assert(client_sock.Send(&req[0], req.size()) != -1);
    assert(client_sock.Send(&req[0], req.size()) != -1);
    assert(client_sock.Send(&req[0], req.size()) != -1);
    assert(client_sock.Send(&req[0], req.size()) != -1);
    assert(client_sock.Send(&req[0], req.size()) != -1);
    assert(client_sock.Send(&req[0], req.size()) != -1);
    assert(client_sock.Send(&req[0], req.size()) != -1);
    assert(client_sock.Send(&req[0], req.size()) != -1);
    assert(client_sock.Send(&req[0], req.size()) != -1);
    char buf[1024] = {0};
    assert(client_sock.Recv(buf, 1023));
    DEBUG_LOG("[%s]", buf);
    sleep(20);
    
    client_sock.Close();
    return 0;
}